<?php
/*
	登录
*/
//cfc('core')->checklogin();
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return['basic']=$this->plugin_setting('basic');
if($_SESSION['uid']){
	if($_SESSION['os']=='windows'){
		exi('您已登陆！','error','jy_weishop/member.index/');
	}else{
		exi('您已登陆！','error','jy_weishop/index/');
	}
}
if($return['pc_set']['no_pc']==1){
	$_SESSION['forward_url']='jy_weishop/member.index/';
	exi('','error','core/member.login/');
}
if($_RQ['op']=='main'){
	
	if($_RQ['postdata']){
		$post=get_postdata();
		$name=trim($post['name']);
		if(empty($name)){
				exi('请输入账号！','error');
			}
		if($post['login_type']==1){
			if(!$post['pwd']){
				exi('请输入密码！','error');
			}
			$user=pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'username'=>$name),array('id','salt','password'));
			if(empty($user)){
				exi('用户不存在，请先注册!','error');
			}
			if(!check_password($post['pwd'],$user['salt'],$user['password'])){
				exi('账号或密码错误!','error');
			}
		
		}else{
			if(!$post['mobile']){
				exi('请输入手机号码！','error');
			}
			if(!$post['pwd']){
				exi('请输入密码！','error');
			}
			$user=pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'mobile'=>$post['mobile']),array('id','salt','password'));
			if(empty($user)){
				exi('用户不存在，请先注册!','error');
			}
			if(!check_password($post['pwd'],$user['salt'],$user['password'])){
				exi('手机号码或密码错误!','error');
			}
		}
		$uid=$user['id'];
		$_SESSION['uid']=$uid;
		$_SESSION['member']=pdo_get('core_members',array('id'=>$uid,'uniacid'=>$_SESSION['uniacid']),array('username','credit1','credit2','nickname','avatar'));
		exi('登录成功！','','jy_weishop/index/');
	}
	if($_SESSION['os']=='windows'){
		$return['session_id']=session_id();
	}
	$return['post']=array(
		'login_type'=>1,
	);
	$_SESSION['forward_url']='jy_weishop/member.index//current_plugin=jy_weishop'; 
	$return['post']['forward_url']=base64_encode($_SESSION['forward_url']);
	exi($return);
}	
?>